home *** CD-ROM | disk | FTP | other *** search
/ DarkBasic Professional / DarkBasicPro.iso / data1.cab / Lang_Files_(English) / Projects / Planet_Potter / Planet Potter.dba next >
Encoding:
Text File  |  2004-09-22  |  4.0 KB  |  185 lines

  1. Rem Project: Planet Potter
  2. Rem Created: 25/07/2002 15:38:30
  3. rem Hours: 5
  4.  
  5. rem Initialise
  6. sync on : sync rate 60 : hide mouse
  7. set text font "Arial" : set text size 20
  8. set text to bold : set text transparent
  9.  
  10. rem Load environment
  11. load object "media\moonlit\ml.x",100
  12. scale object 100,20,20,20
  13. set object cull 100,0
  14. set object light 100,0
  15. set object texture 100,2,1
  16.  
  17. rem Load nine planets
  18. for p=1 to 9
  19.  load object "media\planet\planet.x",p
  20.  position object p,(p-3)*350,0,500
  21.  set object specular p,0
  22.  hide object p
  23. next p
  24.  
  25. rem Load tenth planet for home
  26. load object "media\planet\planet.x",10
  27. position object 10,0,-150,-350
  28. rotate object 10,0,0,90
  29. set object specular 10,0
  30.  
  31. rem Load particle image
  32. load image "media\gfx\fire.bmp",1
  33.  
  34. rem Load player sounds
  35. load sound "media\sounds\shoot.wav",1
  36.  
  37. rem Load game sounds
  38. load sound "media\sounds\appear.wav",11
  39. for s=12 to 19 : clone sound s,11 : next s
  40. load sound "media\sounds\explode.wav",21
  41. for s=22 to 29 : clone sound s,21 : next s
  42.  
  43. rem Setup camera and light
  44. set camera range 0.1,3000
  45. set point light 0,-50,80,-600
  46. set light range 0,2000
  47.  
  48. rem Main Loop
  49. do
  50.  
  51. rem Get ready prompt
  52. center text screen width()/2,screen height()/2,"GET READY!" : sync
  53. sleep 3000 : show mouse
  54.  
  55. rem Starting states
  56. randomize timer()
  57. energy=100 : prate=100
  58. points=0
  59.  
  60. rem Game loop
  61. gameover=0
  62. while gameover=0
  63.  
  64. rem Control player cursor and shot
  65. if mouseclick()=1 and guncool=-1
  66.  rem Shoot effect
  67.  play sound 1 : guncool=3
  68.  rem Detect good hit
  69.  for p=1 to 9
  70.   if object visible(p)=1 and object angle z(p)=0
  71.    sx=object screen x(p)
  72.    sy=object screen y(p)
  73.    mx=mousex() : my=mousey()
  74.    if mx>sx-100 and mx<sx+100 and my>sy-100 and my<sy+100
  75.     zrotate object p,1
  76.     play sound 20+p
  77.     inc points,10
  78.    endif
  79.   endif
  80.  next p
  81. endif
  82. if guncool=0 and mouseclick()=0 then guncool=-1
  83. if guncool>0 then dec guncool
  84.  
  85. rem Control planets
  86. gosub _newplanets
  87. gosub _moveplanets
  88.  
  89. rem Rotate sky backdrop and home planet
  90. yrotate object 100,wrapvalue(object angle y(100)+0.1)
  91. yrotate object 10,wrapvalue(object angle y(10)-0.05)
  92.  
  93. rem Stats
  94. prompt$="SCORE: "+str$(points)
  95. box 40,screen height()-20,41+(energy*3),screen height()-40,0,0,rgb(255,0,0),rgb(255,0,0)
  96. center text screen width()-text width(prompt$),screen height()-40,prompt$
  97.  
  98. rem Update screen
  99. sync
  100.  
  101. rem End loop
  102. endwhile
  103.  
  104. rem High score prompt
  105. hide mouse
  106. center text screen width()/2,screen height()/2,"YOUR SCORE : "+str$(points) : sync
  107. sleep 3000
  108.  
  109. rem Reset objects
  110. for p=1 to 9
  111.  hide object p
  112. next p
  113.  
  114. rem Main endloop
  115. loop
  116. end
  117.  
  118. _newplanets:
  119.  
  120. if pmaker>0 then dec pmaker
  121. if pmaker=0
  122.  p=1 : while object visible(p)=1 and p<9 : inc p : endwhile
  123.  ssx=1000+(prate*10.0)
  124.  ssy=1000+(prate*5.0)
  125.  x=rnd(ssx)-(ssx/2)
  126.  y=rnd(ssy)-(ssy/2)
  127.  position object p,x,y,1000
  128.  scale object p,100,100,100
  129.  rotate object p,0,0,0
  130.  ghost object off p
  131.  play sound 10+p
  132.  show object p
  133.  pmaker=prate+rnd(prate/2)
  134.  if prate>15 then dec prate,5
  135. endif
  136.  
  137. return
  138.  
  139. _moveplanets:
  140.  
  141. rem Move all planets
  142. for p=1 to 9
  143.  `
  144.  if object visible(p)=1 and object angle z(p)=0
  145.   `
  146.   rem Move planet
  147.   sp#=25-(prate/10.0)
  148.   position object p,object position x(p)/1.01,(object position y(p)-1)/1.01,object position z(p)-sp#
  149.   yrotate object p,wrapvalue(object angle y(p)+1)
  150.   if object position z(p)<-600 then hide object p
  151.   `
  152.   rem Detect when hit home planet
  153.   dx#=abs(object position x(p)-object position x(10))
  154.   dy#=abs(object position y(p)-object position y(10))
  155.   dz#=abs(object position z(p)-object position z(10))
  156.   dist#=sqrt((dx#*dx#)+(dy#*dy#)+(dz#*dz#))
  157.   if dist#<300
  158.     zrotate object p,1
  159.     play sound 20+p
  160.     energy=energy-20
  161.     if energy<=0 then gameover=1
  162.   endif
  163.   `
  164.  endif
  165.  `
  166. next p
  167.  
  168. rem Handle planet destruction
  169. for p=1 to 9
  170.  if object angle z(p)>0 and object visible(p)=1
  171.   s=50-object angle z(p)
  172.   ghost object on p,2
  173.   scale object p,s*2,s*2,s*2
  174.   zrotate object p,object angle z(p)+1
  175.   if object angle z(p)>70
  176.    hide object p
  177.   endif
  178.  endif
  179. next p
  180.  
  181. return
  182.  
  183.  
  184.  
  185.